package com.example.duanlei417.mypro2.login.lib_login.core;

import android.content.Context;

public class LoginAssistant {

    private LoginAssistant() {}

    private static LoginAssistant instance;

    public static LoginAssistant getInstance() {
        if (instance == null) {
            synchronized (LoginAssistant.class) {
                if (instance == null) {
                    instance = new LoginAssistant();
                }
            }
        }

        return instance;
    }

    private ILogin mILogin;
    private Context mApplicationContext;

    public ILogin getILogin() {
        return mILogin;
    }

    public void setILogin(ILogin ILogin) {
        mILogin = ILogin;
    }

    public Context getApplicationContext() {
        return mApplicationContext;
    }

    public void setApplicationContext(Context applicationContext) {
        mApplicationContext = applicationContext;
    }

    /**
     * token失效处理
     * @param userDefine
     */
    public void serverTokenInvalidation(int userDefine) {
        if (mILogin == null) {
            return;
        }

        mILogin.clearLoginStatus(mApplicationContext);
        mILogin.login(mApplicationContext, userDefine);
    }
}
